<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务延期列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="task-form">
                <div class="select-list">
                    <ul>
                        <li>
                            申请人：<input type="text" name="userName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:delay:edit">
                <i class="fa fa-edit"></i> 审批
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:delay:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:delay:edit')}]];
    var prefix = ctx + "system/task/approve";
    $(function() {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/edit/{id}",
            exportUrl: prefix + "/export",
            modalName: "任务",
            pagination: true,
            showPageGo: true,
            columns: [{
                checkbox: true
            },
                {
                    field : 'delayId',
                    title : '延期编号',
                    align: 'center',
                    sortable: true
                },
                {
                    field : 'userName',
                    title : '申请人'
                },
                {
                    field : 'delayReason',
                    title : '申请原因'
                },
                {
                    field : 'applicationTime',
                    title : '申请时间',
                    sortable: true
                },
                {
                    field : 'delayTime',
                    title : '申请延期时间',
                    sortable: true
                },
                {
                    field : 'appointedTime',
                    title : '批准延期时间',
                    sortable: true
                },
                {
                    field : 'pass',
                    title : '批复状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(value);
                    }
                },
                {
                    field : 'approvedTime',
                    title : '批复时间',
                    sortable: true
                },
                {
                    field : 'approvedBy',
                    title : '批复人',
                    align: 'center',
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.delayId + '\')"><i class="fa fa-edit"></i>审批</a> ');
                        actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="show(\'' + row.delayId + '\')"><i class="fa fa-search"></i>查看</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function statusTools(value) {
        if (value == 1) {
            return '<p class="badge badge-primary">已同意</p>';
        } else if (value == 0) {
            return '<p class="badge badge-danger">未同意</p>';
        } else {
            return '<p class="badge badge-default">未受理</p>';
        }
    }

    function show(id) {
        layer.open({
            type: 2,
            title: '查看',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['893px', '600px'],
            content: prefix + "/show" + ctx +id
        });
    }

</script>
</body>
</html>